import { Component } from "react";
import { GetAnnounceData } from "@/network/announce/model";
import { GetAnnounce } from "@/network/announce/service";
import { Props, State } from "./model";
import { setToken } from "@/utils/login/ssoLogin";
export default class Service extends Component<Props,State>{
   
    state: Readonly<State>={
        noticeList:[],
        policyFileList:[],
    };

    constructor(props:Props){
        super(props)
    }

    setAnnounce=async (type:number)=>{
        const currentArea=JSON.parse(localStorage.getItem("currentArea") as string);
        return GetAnnounce({
            type:type,
            areaId:currentArea?.key,
            page:1,
            limit:3,
            keyWord:""
        })
    }

    setNotice=async ()=>{
        const data=await this.setAnnounce(1);
        this.setState({
            noticeList:data  as GetAnnounceData
        })
    }
    setPolicyFile=async()=>{
        const data=await this.setAnnounce(2);
        this.setState({
            policyFileList:data  as GetAnnounceData
        })
    }
    
    componentWillMount=async()=>{
        setToken("legalToken")
        this.setNotice();
        this.setPolicyFile();
       
    }

}